#include <iostream>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int N=55;
int a[N][N];
int f[2*N][N][N]; 
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++) cin>>a[i][j];
	}
	for(int k=2;k<=n+m;k++)
	{
		for(int i1=1;i1<=n;i1++)
		{
			int j1=k-i1;
			if(j1>m || j1<1) continue;
			for(int i2=1;i2<=n;i2++)
			{
				int j2=k-i2;
				if(j2>m || j2<1) continue;
				int x=f[k][i1][i2];
				int t=a[i1][j1];
				if(i1!=i2)
				{
					t+=a[i2][j2];
				}
				x=max(x,f[k-1][i1-1][i2-1]+t);
				x=max(x,f[k-1][i1][i2-1]+t);
				x=max(x,f[k-1][i1-1][i2]+t);
				x=max(x,f[k-1][i1][i2]+t);
				f[k][i1][i2]=x;
			}
		}
	}
	cout<<f[n+m][n][n];

	return 0;
}

